package com.by.run;

import com.by.annotion.MyConfiguration;
import com.by.ioc.MyApplicationContext;

/**
 * @version 1.0
 * @Author 彭彦彬
 * @Date 2025/4/9 9:57
 * @注释
 */
public class MySpringApplication {
    private static MyApplicationContext context;

    public static void run(Class<?> configClass, String[] args) throws Exception {
        System.out.println("MySpringApplication is starting...");

        // 初始化上下文
        context = new MyApplicationContext();

        // 扫描包
        if (configClass.isAnnotationPresent(MyConfiguration.class)) {
            MyConfiguration annotation = configClass.getAnnotation(MyConfiguration.class);
            String basePackage = annotation.value();
            context.scanPackage(basePackage);

            // 处理 @Bean 方法

        }

        // 自动注入
        context.autowire();

        System.out.println("MySpringApplication started successfully!");
    }

    public static MyApplicationContext getContext() {
        return context;
    }
}
